import GameOverControl from "./GameOverControl";
import LadderControl from "./LadderControl";
import LadderData from "./LadderData";

/*
 * @Author: LCL 
 * @Date: 2019-03-08 20:36:30
 * @Desc: UI管理器
*/
const {ccclass, property} = cc._decorator;

@ccclass
export default class UIControl extends cc.Component {

    @property(cc.Node)
    moveNode: cc.Node = null;

    @property(cc.Node)
    gameNode: cc.Node = null;

    @property(cc.Node)
    startViewNode: cc.Node = null;

    @property(cc.Node)
    startPopViewNode: cc.Node = null;

    @property(cc.Node)
    gameOverNode: cc.Node = null;

    @property(cc.Node)
    loginNode: cc.Node = null;

    @property(cc.Node)
    rankNode: cc.Node = null;


    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }

    public gotoLogin(){
        this.goOnGame();
        this.loginNode.active = true;
        this.moveNode.active = false;
    }

    public goOnGame(){
        this.startViewNode.active = false;
        this.gameOverNode.active = false;
        this.loginNode.active = false;
        this.rankNode.active = false;
        LadderData.getInstance().gameUICtr.resetGame();
    }

    // update (dt) {}

    public loginStart(){
        this.loginNode.active = false;
        this.startViewNode.active = true;
        // let actionFadeInOut = cc.sequence(
        //     cc.spawn(cc.moveTo(0.3, new cc.Vec2(0, -20)),cc.moveTo(0.2,new cc.Vec2(0, 10)),cc.moveTo(0.2, new cc.Vec2(0, 0))),
        //     cc.callFunc(this.showGameScene, this)
        // )
        // this.startPopViewNode.runAction(actionFadeInOut);


        this.showGameScene();
        this.startPopViewNode.runAction( cc.moveTo( 0.5 ,new cc.Vec2(0, -20)));
        setTimeout(()=>{
            this.startPopViewNode.runAction( cc.moveTo( 0.1 ,new cc.Vec2(0, 10)));
        },500);
        setTimeout(()=>{
            this.startPopViewNode.runAction( cc.moveTo( 0.1 ,new cc.Vec2(0, 0)));
        },700);

    }

    showGameScene(){
        this.moveNode.active = true;
    }

    

    public startGame(){
        // this.startViewNode.active = false;
        // this.gameNode.active = true;
        // let actionFadeInOut = cc.sequence(
        //     cc.spawn(cc.moveTo(0.3, new cc.Vec2(0, 1000))),
        //     cc.callFunc(this.startOnFadeOutFinish, this)
        // )
        // this.startPopViewNode.runAction(actionFadeInOut);

        this.startPopViewNode.runAction( cc.moveTo( 0.2 ,new cc.Vec2(0, 1000)));
        setTimeout(()=>{
            this.startOnFadeOutFinish();
        },200);

        
    }
    startOnFadeOutFinish(){
        this.startViewNode.active = false;
        this.gameNode.active = true;
    }

    public showRank(){
        this.rankNode.active = true;
    }


    public showGameOver(){
        this.gameOverNode.active = true;
        this.gameOverNode.getComponent(GameOverControl).updateScroe();
    }
}

/*
public void TEXT1() 
{
	int textNum = 1;
	if (textNum == 1) 
	{
		textNum = 2;
    }
}
public void TEXT2()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
public void TEXT3()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT4()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT5()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT6()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT8()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT9()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT10()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT11()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT12()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT13()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT14()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT15()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT16()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}

public void TEXT17()
{
    int textNum = 1;
    if (textNum == 1)
    {
        textNum = 2;
    }
}
*/
